﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using GdNet.Web.Assistants;
using GdNet.WebFramework.Business;

namespace GdNet.Integrations.Castle.Installers
{
    public class BusinessInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            var registration = Classes.FromAssemblyContaining<WebFrameworkBusiness>()
                                      .InNamespace(typeof(WebFrameworkBusiness).Namespace, true)
                                      .WithService.DefaultInterfaces();
            registration = ApplicationAssistant.IsWebContext() ? registration.LifestylePerWebRequest() : registration.LifestylePerThread();

            container.Register(registration);
        }
    }
}
